<?php
/**
 * @Notes:【】
 * @User: zwc
 * @Date: 2022-05-27 1:44
 */

namespace App\Service\Statics;

use App\Dao\Order\StoreOrderDao;
use App\Dao\Product\ProductDao;
use App\Dao\Product\StoreProductDao;
use App\Dao\User\UserDao;
use App\Model\User;
use App\Service\Service;
use Hyperf\Di\Annotation\Inject;

class HomeStaticsService extends Service
{

    /**
     * @Inject()
     * @var StoreOrderDao
     */
    protected $storeOrderDao;

    /**
     * @Inject()
     * @var UserDao
     */
    protected $userDao;

    /**
     * @Inject()
     * @var User
     */
    protected $sta;

    public function home()
    {

        $today_sales = $this->storeOrderDao->staticsSales('today');
        $month_sales = $this->storeOrderDao->staticsSales('month');
        $sales = $this->storeOrderDao->staticsSales(null);

        $sales = [
            'value' => $sales,
            'title' => '销售额',
            'tag' => 'All',
            'description' => '本日销售额',
            'description_value' => $today_sales,
            'prefix' => '￥',
        ];

//        $today_visits = $productLogServices->count(['time' => 'today', 'type' => 'visit']);
        $today_add = $this->userDao->staticsAdd('today');
        $month_add = $this->userDao->staticsAdd('month');
        $add = $this->userDao->staticsAdd(null);

        $add = [
            'value' => $add,
            'title' => '用户',
            'tag' => 'All',
            'description' => '今日新增用户',
            'description_value' => $today_add,
            'prefix' => '',
            'suffix' => '人',
        ];

        $goods = App(StoreProductDao::class)->count();
        $today_goods = App(StoreProductDao::class)->yjRangeTime('add_time','today')->count();

        $goods = [
            'value' => $goods,
            'title' => '商品',
            'tag' => 'All',
            'description' => '本日商品数',
            'description_value' => $today_goods,
            'suffix' => '个',
        ];

        $infos = [
            $sales,
            $add,
            $goods,
        ];
        return compact('infos');
    }

}